//
//  HLNetManager.m
//  zhuanxian
//
//  Created by qipai on 2017/11/24.
//  Copyright © 2017年 huiling. All rights reserved.
//

#import "HLNetManager.h"

@implementation HLNetManager

+ (BAURLSessionTask*)hl_requestWithPost:(NSString*)url param:(id)param withSuccessBlock:(BAResponseSuccessBlock)successBlock withFailureBlock:(BAResponseFailBlock)failureBlock progressBlock:(BADownloadProgressBlock)progressBlock {
    BADataEntity* entity = [BADataEntity new];
    entity.urlString = url;
    entity.parameters = param;
    entity.needCache = NO;
    return [BANetManager ba_request_POSTWithEntity:entity successBlock:successBlock failureBlock:failureBlock progressBlock:progressBlock];
}

+ (BAURLSessionTask*)hl_requestWithGet:(NSString*)url param:(id)param withSuccessBlock:(BAResponseSuccessBlock)successBlock withFailureBlock:(BAResponseFailBlock)failureBlock progressBlock:(BADownloadProgressBlock)progressBlock {
    BADataEntity* entity = [BADataEntity new];
    entity.urlString = url;
    entity.parameters = param;
    entity.needCache = NO;
    return [BANetManager ba_request_GETWithEntity:entity successBlock:successBlock failureBlock:failureBlock progressBlock:progressBlock];
}

+ (BAURLSessionTask*)hl_uploadImages:(NSString*)url param:(id)param images:(NSArray<UIImage*>*)images withSuccessBlock:(BAResponseSuccessBlock)successBlock withFailureBlock:(BAResponseFailBlock)failureBlock progressBlock:(BAUploadProgressBlock)progressBlock {
    BAImageDataEntity* entity = [BAImageDataEntity new];
    entity.urlString = url;
    entity.parameters = param;
    entity.needCache = NO;
    entity.imageArray = images;
    NSMutableArray* arrayFileNames = [NSMutableArray new];
    for (int i=0; i<images.count; i++) {
        [arrayFileNames addObject:[NSString stringWithFormat:@"picfile%zd",i+1]];
    }
    entity.fileNames = arrayFileNames;
    entity.imageType = @"image/jpeg";
    entity.imageScale = 0.8;
    return [BANetManager ba_uploadImageWithEntity:entity successBlock:successBlock failurBlock:failureBlock progressBlock:progressBlock];
}

@end
